home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / hardware.656 < prev    next >
Text File  |  1992-02-06  |  1KB  |  28 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;\f2\fswiss Helvetica;}
  2. \paperw11040
  3. \paperh7620
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs28 \
  8. Q:  I'm writing a program that needs to generate code on the fly and execute it.  This worked fine on the 68030,  but now that I try it on the 68040 it doesn't work.  What am I doing wrong?\
  9. \
  10. A:  Certain programs, most notably program language interpreters, need to generate opcodes at run-time and execute them. This worked as expected on the 68030,  but on the 68040 architecture, it is necessary to flush the instruction cache to insure that your code is executed properly.  To do this,  you need to call a hardware trap (trap number 2).  You can use the "asm" C function to place this assembly language call inline in your C code:\
  11. \
  12.  
  13. \f1     asm("trap #2");\
  14.  
  15. \f0     \
  16. This call will flush the 4K of memory allocated to the Data and Instruction caches.  There currently is no call on our system that selectively flushes part (or one) of these two caches.\
  17. \
  18. This call will not do anything harmful on 68030 machines,  so it is not necessary to check which architecture you are running on.\
  19. \
  20. QA 
  21. \pard\tx533\tx1067\tx1601\tx2135\tx2668\tx3202\tx3736\tx4270\tx4803\tx5337\fc0 656
  22. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  23. \
  24.  
  25. Valid for 2.0 on the '040,  does nothing harmful on the '030\
  26. \
  27.  
  28.